Skip to content

Commit a5177e1

Browse files
olhotaknoti0na1
authored andcommitted
partially address review comments
1 parent 2ecc091 commit a5177e1

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeErasure.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,8 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
663663
case tp: TypeVar if !tp.isInstantiated =>
664664
assert(inSigName, i"Cannot erase uninstantiated type variable $tp")
665665
WildcardType
666-
case FlexibleType(tp) => this(tp)
666+
case tp: FlexibleType =>
667+
this(tp.underlying)
667668
case tp: TypeProxy =>
668669
this(tp.underlying)
669670
case tp @ AndType(tp1, tp2) =>

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3404,6 +3404,11 @@ object Types {
34043404

34053405
// --- FlexibleType -----------------------------------------------------------------
34063406

3407+
/* Represents a nullable type coming from Java code in a similar way to Platform Types
3408+
* in Kotlin. A FlexibleType(T) generally behaves like an abstract type with bad bounds
3409+
* T|Null .. T, so that T|Null <: FlexibleType(T) <: T.
3410+
*/
3411+
34073412
object FlexibleType {
34083413
def apply(underlying: Type) = underlying match {
34093414
case ft: FlexibleType => ft
@@ -3412,7 +3417,6 @@ object Types {
34123417
}
34133418
case class FlexibleType(underlying: Type) extends CachedGroundType with ValueType {
34143419
def lo(using Context): Type = OrNull(underlying)
3415-
override def show(using Context) = i"FlexibleType($underlying)"
34163420
def derivedFlexibleType(under: Type)(using Context): Type =
34173421
if this.underlying eq under then this else FlexibleType(under)
34183422
override def computeHash(bs: Binders): Int = doHash(bs, underlying)

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ class PlainPrinter(_ctx: Context) extends Printer {
289289
case AnnotatedType(tpe, annot) =>
290290
if annot.symbol == defn.InlineParamAnnot || annot.symbol == defn.ErasedParamAnnot then toText(tpe)
291291
else toTextLocal(tpe) ~ " " ~ toText(annot)
292+
case FlexibleType(tpe) =>
293+
"FlexibleType(" ~ toText(tpe) ~ ")"
292294
case tp: TypeVar =>
293295
def toTextCaret(tp: Type) = if printDebug then toTextLocal(tp) ~ Str("^") else toText(tp)
294296
if (tp.isInstantiated)

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
564564
val s = combineApiTypes(apiType(tp.tp1), apiType(tp.tp2))
565565
withMarker(s, orMarker)
566566
case tp: FlexibleType =>
567+
// TODO: determine whether this is the right behaviour for sbt
567568
apiType(tp.underlying)
568569
case ExprType(resultType) =>
569570
withMarker(apiType(resultType), byNameMarker)

0 commit comments

Comments
 (0)