Skip to content

Commit 6b21e47

Browse files
authored
Merge pull request #3602 from dotty-staging/drop-typeargref
Replace TypeArgRefs by normal TypeRefs
2 parents 33ebbb8 + d652e0d commit 6b21e47

24 files changed

+345
-363
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class ScalaSettings extends Settings.SettingGroup {
102102
val YplainPrinter = BooleanSetting("-Yplain-printer", "Pretty-print using a plain printer.")
103103
val YprintSyms = BooleanSetting("-Yprint-syms", "when printing trees print info in symbols instead of corresponding info in trees.")
104104
val YprintDebug = BooleanSetting("-Yprint-debug", "when printing trees, print some extra information useful for debugging.")
105+
val YshowPrintErrors = BooleanSetting("-Yshow-print-errors", "don't suppress exceptions thrown during tree printing.")
105106
val YtestPickler = BooleanSetting("-Ytest-pickler", "self-test for pickling functionality; should be used with -Ystop-after:pickler")
106107
val YcheckReentrant = BooleanSetting("-Ycheck-reentrant", "check that compiled program does not contain vars that can be accessed from a global root.")
107108
val YkeepComments = BooleanSetting("-Ykeep-comments", "Keep comments when scanning source files.")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Definitions {
6767
enterTypeField(cls, name, flags | ClassTypeParamCreationFlags, scope)
6868

6969
private def enterSyntheticTypeParam(cls: ClassSymbol, paramFlags: FlagSet, scope: MutableScope, suffix: String = "T0") =
70-
enterTypeParam(cls, suffix.toTypeName.expandedName(cls), paramFlags, scope)
70+
enterTypeParam(cls, suffix.toTypeName, paramFlags, scope)
7171

7272
// NOTE: Ideally we would write `parentConstrs: => Type*` but SIP-24 is only
7373
// implemented in Dotty and not in Scala 2.

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Names._
66
import NameOps._
77
import StdNames._
88
import util.DotClass
9-
import tasty.TastyFormat._
9+
import NameTags._
1010
import Decorators._
1111
import Contexts.Context
1212
import collection.mutable
@@ -358,7 +358,6 @@ object NameKinds {
358358
override def mkString(underlying: TermName, info: ThisInfo) = underlying.toString
359359
}
360360
val ExtMethName = new SuffixNameKind(EXTMETH, "$extension")
361-
val ModuleVarName = new SuffixNameKind(OBJECTVAR, "$module")
362361
val ModuleClassName = new SuffixNameKind(OBJECTCLASS, "$", optInfoString = "ModuleClass")
363362
val ImplMethName = new SuffixNameKind(IMPLMETH, "$")
364363
val AdaptedClosureName = new SuffixNameKind(ADAPTEDCLOSURE, "$adapted") { override def definesNewName = true }
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package dotty.tools
2+
package dotc
3+
package core
4+
5+
import tasty.TastyFormat
6+
7+
/** The possible tags of a NameKind */
8+
object NameTags extends TastyFormat.NameTags {
9+
10+
final val FLATTENED = 5 // A flat name, generated by Flatten
11+
12+
final val TRAITSETTER = 6 // A Scala-2 trait setter, generated by AugmentScala2Traits
13+
14+
final val INITIALIZER = 24 // A mixin initializer method
15+
16+
final val AVOIDCLASH = 25 // Adds a suffix to avoid a name clash;
17+
// Used in FirstTransform for synthesized companion objects of classes
18+
// if they would clash with another value.
19+
20+
final val DIRECT = 26 // Used by ShortCutImplicits for the name of methods that
21+
// implement implicit function result types directly.
22+
23+
final val FIELD = 27 // Used by Memoize to tag the name of a class member field.
24+
25+
final val EXTMETH = 28 // Used by ExtensionMethods for the name of an extension method
26+
// implementing a value class method.
27+
28+
final val ADAPTEDCLOSURE = 29 // Used in Erasure to adapt closures over primitive types.
29+
30+
final val IMPLMETH = 30 // Used to define methods in implementation classes
31+
// (can probably be removed).
32+
33+
def nameTagToString(tag: Int): String = tag match {
34+
case UTF8 => "UTF8"
35+
case QUALIFIED => "QUALIFIED"
36+
case FLATTENED => "FLATTENED"
37+
case EXPANDED => "EXPANDED"
38+
case EXPANDPREFIX => "EXPANDPREFIX"
39+
case TRAITSETTER => "TRAITSETTER"
40+
case UNIQUE => "UNIQUE"
41+
case DEFAULTGETTER => "DEFAULTGETTER"
42+
case VARIANT => "VARIANT"
43+
case OUTERSELECT => "OUTERSELECT"
44+
45+
case SUPERACCESSOR => "SUPERACCESSOR"
46+
case PROTECTEDACCESSOR => "PROTECTEDACCESSOR"
47+
case PROTECTEDSETTER => "PROTECTEDSETTER"
48+
case INITIALIZER => "INITIALIZER"
49+
case AVOIDCLASH => "AVOIDCLASH"
50+
case DIRECT => "DIRECT"
51+
case FIELD => "FIELD"
52+
case EXTMETH => "EXTMETH"
53+
case ADAPTEDCLOSURE => "ADAPTEDCLOSURE"
54+
case OBJECTCLASS => "OBJECTCLASS"
55+
56+
case SIGNED => "SIGNED"
57+
}
58+
}

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -531,14 +531,6 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
531531
case _ => isSubType(tp1.widenExpr, restpe2)
532532
}
533533
compareExpr
534-
case tp2: TypeArgRef =>
535-
def sameTypeArgRef = tp1 match {
536-
case tp1: TypeArgRef =>
537-
tp1.clsRef == tp2.clsRef && tp1.idx == tp2.idx && tp1.prefix =:= tp2.prefix
538-
case _ =>
539-
false
540-
}
541-
sameTypeArgRef || isSubType(tp1, tp2.underlying.loBound) || fourthTry(tp1, tp2)
542534
case tp2 @ TypeBounds(lo2, hi2) =>
543535
def compareTypeBounds = tp1 match {
544536
case tp1 @ TypeBounds(lo1, hi1) =>
@@ -609,8 +601,6 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
609601
isNewSubType(tp1.parent, tp2)
610602
case tp1: RecType =>
611603
isNewSubType(tp1.parent, tp2)
612-
case tp1: TypeArgRef =>
613-
isSubType(tp1.underlying.hiBound, tp2)
614604
case tp1: HKTypeLambda =>
615605
def compareHKLambda = tp1 match {
616606
case EtaExpansion(tycon1) => isSubType(tycon1, tp2)
@@ -833,7 +823,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
833823

834824
def compareCaptured(arg1: Type, arg2: Type): Boolean = arg1 match {
835825
case arg1: TypeBounds =>
836-
val captured = TypeArgRef.fromParam(tp1, tparam.asInstanceOf[TypeSymbol])
826+
val captured = TypeRef(tp1, tparam.asInstanceOf[TypeSymbol])
837827
isSubArg(captured, arg2)
838828
case _ =>
839829
false

0 commit comments

Comments
 (0)