Skip to content

Commit b3e4cf2

Browse files
committed
Encode qualifier arguments as E-Nodes
1 parent f691b84 commit b3e4cf2

31 files changed

+999
-604
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,8 @@ object desugar {
25622562
tree
25632563

25642564
if Feature.qualifiedTypesEnabled then
2565-
transform(tpt)
2565+
trace(i"desugar qualified types in pattern: $tpt", Printers.qualifiedTypes):
2566+
transform(tpt)
25662567
else
25672568
tpt
25682569

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,11 @@ class Definitions {
617617
@tu lazy val Int_/ : Symbol = IntClass.requiredMethod(nme.DIV, List(IntType))
618618
@tu lazy val Int_* : Symbol = IntClass.requiredMethod(nme.MUL, List(IntType))
619619
@tu lazy val Int_== : Symbol = IntClass.requiredMethod(nme.EQ, List(IntType))
620+
@tu lazy val Int_!= : Symbol = IntClass.requiredMethod(nme.NE, List(IntType))
620621
@tu lazy val Int_>= : Symbol = IntClass.requiredMethod(nme.GE, List(IntType))
621622
@tu lazy val Int_<= : Symbol = IntClass.requiredMethod(nme.LE, List(IntType))
622623
@tu lazy val Int_> : Symbol = IntClass.requiredMethod(nme.GT, List(IntType))
624+
@tu lazy val Int_< : Symbol = IntClass.requiredMethod(nme.LT, List(IntType))
623625
@tu lazy val LongType: TypeRef = valueTypeRef("scala.Long", java.lang.Long.TYPE, LongEnc, nme.specializedTypeNames.Long)
624626
def LongClass(using Context): ClassSymbol = LongType.symbol.asClass
625627
@tu lazy val Long_+ : Symbol = LongClass.requiredMethod(nme.PLUS, List(LongType))

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
889889
throw ex
890890
compareCapturing || fourthTry
891891
case QualifiedType(parent2, qualifier2) =>
892-
QualifiedTypes.typeImplies(tp1, qualifier2) && recur(tp1, parent2)
892+
val parentSub = recur(tp1, parent2)
893+
val qualifierSub = QualifiedTypes.typeImplies(tp1, qualifier2)
894+
//println(i"compare qualified $tp1 <:< $tp2, parentSub = $parentSub, qualifierSub = $qualifierSub")
895+
parentSub && qualifierSub
893896
case tp2: AnnotatedType if tp2.isRefining =>
894897
(tp1.derivesAnnotWith(tp2.annot.sameAnnotation) || tp1.isBottomType) &&
895898
recur(tp1, tp2.parent)

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import compiletime.uninitialized
4141
import cc.*
4242
import CaptureSet.IdentityCaptRefMap
4343
import Capabilities.*
44-
import qualified_types.QualifiedType
44+
import qualified_types.{QualifiedType, QualifiedAnnotation}
4545
import scala.annotation.internal.sharable
4646
import scala.annotation.threadUnsafe
4747

@@ -5884,7 +5884,8 @@ object Types extends TypeUtils {
58845884
def make(underlying: Type, annots: List[Annotation])(using Context): Type =
58855885
annots.foldLeft(underlying)(apply(_, _))
58865886
def apply(parent: Type, annot: Annotation)(using Context): AnnotatedType =
5887-
unique(CachedAnnotatedType(parent, annot))
5887+
val annot1 = if annot.symbol == defn.QualifiedAnnot then QualifiedAnnotation(annot) else annot
5888+
unique(CachedAnnotatedType(parent, annot1))
58885889
end AnnotatedType
58895890

58905891
// Special type objects and classes -----------------------------------------------------

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ object Parsers {
16591659
* | `(' [ FunArgType {`,' FunArgType } ] `)'
16601660
* | '(' [ TypedFunParam {',' TypedFunParam } ')'
16611661
* MatchType ::= InfixType `match` <<< TypeCaseClauses >>>
1662-
* QualifiedType2 ::= InfixType `with` PostfixExprf
1662+
* QualifiedType2 ::= InfixType `with` PostfixExpr
16631663
* IntoType ::= [‘into’] IntoTargetType
16641664
* | ‘( IntoType ‘)’
16651665
* IntoTargetType ::= Type
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package dotty.tools.dotc.qualified_types
2+
import dotty.tools.dotc.core.Types.{
3+
SingletonType,
4+
CachedProxyType,
5+
Type
6+
}
7+
import dotty.tools.dotc.core.Contexts.Context
8+
import dotty.tools.dotc.core.Hashable.Binders
9+
10+
11+
/** Reference to the argument of an [[ENode.Lambda]].
12+
*
13+
* @param index 
14+
* Debruijn index of the argument, starting from 0
15+
* @param underyling
16+
* Underlying type of the argument
17+
*/
18+
final case class ENodeParamRef(index: Int, underlying: Type) extends CachedProxyType, SingletonType:
19+
override def underlying(using Context): Type = underlying
20+
override def computeHash(bs: Binders): Int = doHash(bs, index, underlying)

0 commit comments

Comments
 (0)