Skip to content

Commit e3ea462

Browse files
committed
partially address review comments
1 parent 58818e9 commit e3ea462

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

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

+2-1
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

+5-1
Original file line numberDiff line numberDiff line change
@@ -3363,6 +3363,11 @@ object Types {
33633363

33643364
// --- FlexibleType -----------------------------------------------------------------
33653365

3366+
/* Represents a nullable type coming from Java code in a similar way to Platform Types
3367+
* in Kotlin. A FlexibleType(T) generally behaves like an abstract type with bad bounds
3368+
* T|Null .. T, so that T|Null <: FlexibleType(T) <: T.
3369+
*/
3370+
33663371
object FlexibleType {
33673372
def apply(underlying: Type) = underlying match {
33683373
case ft: FlexibleType => ft
@@ -3371,7 +3376,6 @@ object Types {
33713376
}
33723377
case class FlexibleType(underlying: Type) extends CachedGroundType with ValueType {
33733378
def lo(using Context): Type = OrNull(underlying)
3374-
override def show(using Context) = i"FlexibleType($underlying)"
33753379
def derivedFlexibleType(under: Type)(using Context): Type =
33763380
if this.underlying eq under then this else FlexibleType(under)
33773381
override def computeHash(bs: Binders): Int = doHash(bs, underlying)

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

+2
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ class PlainPrinter(_ctx: Context) extends Printer {
264264
case AnnotatedType(tpe, annot) =>
265265
if annot.symbol == defn.InlineParamAnnot || annot.symbol == defn.ErasedParamAnnot then toText(tpe)
266266
else toTextLocal(tpe) ~ " " ~ toText(annot)
267+
case FlexibleType(tpe) =>
268+
"FlexibleType(" ~ toText(tpe) ~ ")"
267269
case tp: TypeVar =>
268270
def toTextCaret(tp: Type) = if printDebug then toTextLocal(tp) ~ Str("^") else toText(tp)
269271
if (tp.isInstantiated)

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

+1
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)