Skip to content

Commit 35b32df

Browse files
committed
Encode qualifier arguments as E-Nodes
1 parent 01a19cf commit 35b32df

29 files changed

+991
-587
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2491,7 +2491,8 @@ object desugar {
24912491
tree
24922492

24932493
if Feature.qualifiedTypesEnabled then
2494-
transform(tpt)
2494+
trace(i"desugar qualified types in pattern: $tpt", Printers.qualifiedTypes):
2495+
transform(tpt)
24952496
else
24962497
tpt
24972498

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,11 @@ class Definitions {
616616
@tu lazy val Int_/ : Symbol = IntClass.requiredMethod(nme.DIV, List(IntType))
617617
@tu lazy val Int_* : Symbol = IntClass.requiredMethod(nme.MUL, List(IntType))
618618
@tu lazy val Int_== : Symbol = IntClass.requiredMethod(nme.EQ, List(IntType))
619+
@tu lazy val Int_!= : Symbol = IntClass.requiredMethod(nme.NE, List(IntType))
619620
@tu lazy val Int_>= : Symbol = IntClass.requiredMethod(nme.GE, List(IntType))
620621
@tu lazy val Int_<= : Symbol = IntClass.requiredMethod(nme.LE, List(IntType))
621622
@tu lazy val Int_> : Symbol = IntClass.requiredMethod(nme.GT, List(IntType))
623+
@tu lazy val Int_< : Symbol = IntClass.requiredMethod(nme.LT, List(IntType))
622624
@tu lazy val LongType: TypeRef = valueTypeRef("scala.Long", java.lang.Long.TYPE, LongEnc, nme.specializedTypeNames.Long)
623625
def LongClass(using Context): ClassSymbol = LongType.symbol.asClass
624626
@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
@@ -886,7 +886,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
886886
throw ex
887887
compareCapturing || fourthTry
888888
case QualifiedType(parent2, qualifier2) =>
889-
QualifiedTypes.typeImplies(tp1, qualifier2) && recur(tp1, parent2)
889+
val parentSub = recur(tp1, parent2)
890+
val qualifierSub = QualifiedTypes.typeImplies(tp1, qualifier2)
891+
//println(i"compare qualified $tp1 <:< $tp2, parentSub = $parentSub, qualifierSub = $qualifierSub")
892+
parentSub && qualifierSub
890893
case tp2: AnnotatedType if tp2.isRefining =>
891894
(tp1.derivesAnnotWith(tp2.annot.sameAnnotation) || tp1.isBottomType) &&
892895
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

@@ -5833,7 +5833,8 @@ object Types extends TypeUtils {
58335833
def make(underlying: Type, annots: List[Annotation])(using Context): Type =
58345834
annots.foldLeft(underlying)(apply(_, _))
58355835
def apply(parent: Type, annot: Annotation)(using Context): AnnotatedType =
5836-
unique(CachedAnnotatedType(parent, annot))
5836+
val annot1 = if annot.symbol == defn.QualifiedAnnot then QualifiedAnnotation(annot) else annot
5837+
unique(CachedAnnotatedType(parent, annot1))
58375838
end AnnotatedType
58385839

58395840
// 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
@@ -1647,7 +1647,7 @@ object Parsers {
16471647
* | `(' [ FunArgType {`,' FunArgType } ] `)'
16481648
* | '(' [ TypedFunParam {',' TypedFunParam } ')'
16491649
* MatchType ::= InfixType `match` <<< TypeCaseClauses >>>
1650-
* QualifiedType2 ::= InfixType `with` PostfixExprf
1650+
* QualifiedType2 ::= InfixType `with` PostfixExpr
16511651
* IntoType ::= [‘into’] IntoTargetType
16521652
* | ‘( IntoType ‘)’
16531653
* 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)