Skip to content

Commit

Permalink
partially address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
olhotak committed Jul 31, 2023
1 parent 58818e9 commit e3ea462
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeErasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,8 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
case tp: TypeVar if !tp.isInstantiated =>
assert(inSigName, i"Cannot erase uninstantiated type variable $tp")
WildcardType
case FlexibleType(tp) => this(tp)
case tp: FlexibleType =>
this(tp.underlying)
case tp: TypeProxy =>
this(tp.underlying)
case tp @ AndType(tp1, tp2) =>
Expand Down
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3363,6 +3363,11 @@ object Types {

// --- FlexibleType -----------------------------------------------------------------

/* Represents a nullable type coming from Java code in a similar way to Platform Types
* in Kotlin. A FlexibleType(T) generally behaves like an abstract type with bad bounds
* T|Null .. T, so that T|Null <: FlexibleType(T) <: T.
*/

object FlexibleType {
def apply(underlying: Type) = underlying match {
case ft: FlexibleType => ft
Expand All @@ -3371,7 +3376,6 @@ object Types {
}
case class FlexibleType(underlying: Type) extends CachedGroundType with ValueType {
def lo(using Context): Type = OrNull(underlying)
override def show(using Context) = i"FlexibleType($underlying)"
def derivedFlexibleType(under: Type)(using Context): Type =
if this.underlying eq under then this else FlexibleType(under)
override def computeHash(bs: Binders): Int = doHash(bs, underlying)
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ class PlainPrinter(_ctx: Context) extends Printer {
case AnnotatedType(tpe, annot) =>
if annot.symbol == defn.InlineParamAnnot || annot.symbol == defn.ErasedParamAnnot then toText(tpe)
else toTextLocal(tpe) ~ " " ~ toText(annot)
case FlexibleType(tpe) =>
"FlexibleType(" ~ toText(tpe) ~ ")"
case tp: TypeVar =>
def toTextCaret(tp: Type) = if printDebug then toTextLocal(tp) ~ Str("^") else toText(tp)
if (tp.isInstantiated)
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
val s = combineApiTypes(apiType(tp.tp1), apiType(tp.tp2))
withMarker(s, orMarker)
case tp: FlexibleType =>
// TODO: determine whether this is the right behaviour for sbt
apiType(tp.underlying)
case ExprType(resultType) =>
withMarker(apiType(resultType), byNameMarker)
Expand Down

0 comments on commit e3ea462

Please sign in to comment.