aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala4
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala2
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala5
-rw-r--r--src/dotty/tools/dotc/core/Types.scala26
4 files changed, 19 insertions, 18 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index 9018d4015..304d9853c 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -377,9 +377,9 @@ class Definitions {
}
object ArrayType {
- def apply(elem: Type) =
+ def apply(elem: Type)(implicit ctx: Context) =
ArrayClass.typeRef.appliedTo(elem :: Nil)
- def unapply(tp: Type) = tp.dealias match {
+ def unapply(tp: Type)(implicit ctx: Context) = tp.dealias match {
case at: RefinedType if (at isRef ArrayClass) && at.argInfos.length == 1 => Some(at.argInfos.head)
case _ => None
}
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 7ba6bbec6..63ce7f756 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -922,7 +922,7 @@ object SymDenotations {
/** The type parameters of this class */
override final def typeParams(implicit ctx: Context): List[TypeSymbol] = {
def computeTypeParams = {
- if (ctx.phase.erasedTypes && (this ne defn.ArrayClass)) Nil
+ if (ctx.phase.erasedTypes && (symbol ne defn.ArrayClass)) Nil
else if (this ne initial) initial.asSymDenotation.typeParams
else decls.filter(sym =>
(sym is TypeParam) && sym.owner == symbol).asInstanceOf[List[TypeSymbol]]
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index 4d818cc6f..29f6dda69 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -11,7 +11,7 @@ import printing.Disambiguation.disambiguated
import util.{Stats, DotClass, SimpleMap}
import config.Config
import config.Printers._
-import TypeErasure.erasedLub
+import TypeErasure.{erasedLub, erasedGlb}
/** Provides methods to compare types.
*/
@@ -1066,12 +1066,13 @@ class TypeComparer(initctx: Context) extends DotClass {
* Such TypeBounds can also be arbitrarily instantiated. In both cases we need to
* make sure that such types do not actually arise in source programs.
*/
- final def andType(tp1: Type, tp2: Type) = ctx.traceIndented(s"glb(${tp1.show}, ${tp2.show})", subtyping, show = true) {
+ final def andType(tp1: Type, tp2: Type, erased: Boolean = ctx.erasedTypes) = ctx.traceIndented(s"glb(${tp1.show}, ${tp2.show})", subtyping, show = true) {
val t1 = distributeAnd(tp1, tp2)
if (t1.exists) t1
else {
val t2 = distributeAnd(tp2, tp1)
if (t2.exists) t2
+ else if (erased) erasedGlb(tp1, tp2, isJava = false)
else {
//if (isHKRef(tp1)) tp2
//else if (isHKRef(tp2)) tp1
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index a8bfe61e0..e59c28ca2 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -21,7 +21,7 @@ import ast.tpd._
import ast.TreeTypeMap
import printing.Texts._
import ast.untpd
-import transform.Erasure
+import dotty.tools.dotc.transform.Erasure
import printing.Printer
import Hashable._
import Uniques._
@@ -2183,17 +2183,17 @@ object Types {
def selfType(implicit ctx: Context): Type = {
if (selfTypeCache == null) {
def fullRef = fullyAppliedRef(cls.typeRef, cls.typeParams)
- selfTypeCache =
- if (ctx.erasedTypes) fullRef
- else selfInfo match {
- case NoType =>
- fullRef
- case tp: Type =>
- if (cls is Module) tp else AndType(tp, fullRef)
- case self: Symbol =>
- assert(!(cls is Module))
- AndType(self.info, fullRef)
- }
+ def withFullRef(tp: Type): Type =
+ if (ctx.erasedTypes) fullRef else AndType(tp, fullRef)
+ selfTypeCache = selfInfo match {
+ case NoType =>
+ fullRef
+ case tp: Type =>
+ if (cls is Module) tp else withFullRef(tp)
+ case self: Symbol =>
+ assert(!(cls is Module))
+ withFullRef(self.info)
+ }
}
selfTypeCache
}
@@ -2210,7 +2210,7 @@ object Types {
}
def rebase(tp: Type)(implicit ctx: Context): Type =
- if ((prefix eq cls.owner.thisType) || !cls.owner.isClass) tp
+ if ((prefix eq cls.owner.thisType) || !cls.owner.isClass || ctx.erasedTypes) tp
else tp.substThis(cls.owner.asClass, prefix)
private var typeRefCache: Type = null