Skip to content

Commit bdd991c

Browse files
authored
Merge branch 'scala:main' into hr/trigger-cc-tests
2 parents 4ef2a6d + 300043e commit bdd991c

File tree

91 files changed

+539
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+539
-232
lines changed

MAINTENANCE.md

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,39 +63,48 @@ At the end of their supervision period, the supervisor reports to the team durin
6363

6464
## Maintenance List
6565

66-
The following is the list of all the principal areas of the compiler and the core team members who are responsible for their maintenance:
66+
The following is the list of all the principal areas of the compiler and the internal team members who are responsible for their maintenance:
6767

6868
### Compiler
69-
- Parser: @odersky, @hamzaremmal
70-
- Typer: @odersky, @smarter, (@dwijnand), @noti0nal
69+
- Parser: @odersky, @hamzaremmal, @KacperFKorban
70+
- Typer: @odersky, @smarter, (@dwijnand), @noti0nal, @EugeneFlesselle, @KacperFKorban, @bracevac
7171
- Erasure: @smarter, @odersky
72-
- Enums: @bishabosha
73-
- Derivation & Mirrors: @bishabosha, (@dwijnand), @EugeneFlesselle
74-
- Export: @bishabosha, @odersky
75-
- Pattern Matching: @dwijnand, (@liufengyun), @sjrd
76-
- Inline: @nicolasstucki, @odersky, @hamzaremmal
77-
- Metaprogramming (Quotes, Reflect, Staging): @nicolasstucki, @jchyb, @hamzaremmal
78-
- Match types: @sjrd, @dwijnand, @Decel, @Linyxus
72+
- Enums:
73+
- Derivation & Mirrors: (@dwijnand), @EugeneFlesselle
74+
- Export: @odersky
75+
- Pattern Matching: @dwijnand, @sjrd, @noti0na1
76+
- Inline: @odersky, @jchyb, @hamzaremmal, @EugeneFlesselle
77+
- Metaprogramming (Quotes, Reflect, Staging): @jchyb, @hamzaremmal
78+
- Match types: @sjrd, @dwijnand, @Linyxus, @EugeneFlesselle
7979
- GADT: @dwijnand, @Linyxus
80-
- Initialization checker: @olhotak, @liufengyun
81-
- Safe nulls: @noti0na1, @olhotak
82-
- Transforms: @szymon-rd, @sjrd, @odersky, @smarter
83-
- tailrec: @sjrd, @mbovel
80+
- Initialization checker:
81+
- Transforms: @sjrd, @odersky, @smarter
82+
- Tailrec: @sjrd, @mbovel
8483
- JS backend: @sjrd
85-
- JVM backend: @sjrd
86-
- Java-compat: @smarter, @dwijnand
87-
- Capture checker: @odersky, @Linyxus
84+
- JVM backend: @sjrd, @hamzaremmal
85+
- Java-compat: @smarter, @dwijnand, @hamzaremmal
86+
- Extension Methods: @odersky, @dwijnand
87+
- Safe nulls (experimental): @noti0na1
88+
- Capture checker (experimental): @odersky, @Linyxus, @bracevac, @noti0na1
89+
- Modularity (experimental): @KacperFKorban
90+
- Named Tuples (experimental): @odersky
8891

8992
### Tooling
90-
- REPL: @dwijnand, @prolativ
93+
- REPL: @dwijnand
94+
- Runner/CLI: @Gedochao, (@tgodzik)
95+
- IDE: @tgodzik, (@kasiaMarek)
9196
- Scaladoc: @Florian3k
92-
- SemanticDB: @tanishiking
93-
- Coverage: @TheElectronWill
94-
- Linting (especially unused warnings) / Reporting UX: @szymon-rd
97+
- SemanticDB: @natsukagami, (@tanishiking)
98+
- Coverage: @KacperFKorban
99+
- Linting (especially unused warnings) / Reporting UX: @KacperFKorban
100+
- Presentation Compiler: @rochala, @tgodzik, @kasiaMarek, @natsukagami
101+
- Debug Adapter: @adpi2, (@tgodzik)
102+
- Scastie: @rochala
95103

96104
### Infrastructure
97-
- CI: @hamzaremmal
105+
- CI: @hamzaremmal, (@WojciechMazur)
98106
- Community Build: @hamzaremmal
99107
- Open Community Build: @WojciechMazur
100-
- Vulpix: @dwijnand, @prolativ
108+
- Vulpix: @dwijnand, @prolativ, @hamzaremmal
101109
- Benchmarks: @mbovel
110+
- Releases: @WojciechMazur, @prolativ

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ trait TreeInfo[T <: Untyped] { self: Trees.Instance[T] =>
144144
def allTermArguments(tree: Tree): List[Tree] = unsplice(tree) match {
145145
case Apply(fn, args) => allTermArguments(fn) ::: args
146146
case TypeApply(fn, args) => allTermArguments(fn)
147-
case Block(_, expr) => allTermArguments(expr)
147+
case Block(Nil, expr) => allTermArguments(expr)
148148
case _ => Nil
149149
}
150150

151151
/** All type and term arguments of an application in a single flattened list */
152152
def allArguments(tree: Tree): List[Tree] = unsplice(tree) match {
153153
case Apply(fn, args) => allArguments(fn) ::: args
154154
case TypeApply(fn, args) => allArguments(fn) ::: args
155-
case Block(_, expr) => allArguments(expr)
155+
case Block(Nil, expr) => allArguments(expr)
156156
case _ => Nil
157157
}
158158

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,13 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
527527
def makeCapsOf(tp: RefTree)(using Context): Tree =
528528
TypeApply(Select(scalaDot(nme.caps), nme.capsOf), tp :: Nil)
529529

530-
def makeCapsBound()(using Context): Tree =
531-
makeRetaining(
530+
// Capture set variable `[C^]` becomes: `[C >: CapSet <: CapSet^{cap}]`
531+
def makeCapsBound()(using Context): TypeBoundsTree =
532+
TypeBoundsTree(
532533
Select(scalaDot(nme.caps), tpnme.CapSet),
533-
Nil, tpnme.retainsCap)
534+
makeRetaining(
535+
Select(scalaDot(nme.caps), tpnme.CapSet),
536+
Nil, tpnme.retainsCap))
534537

535538
def makeConstructor(tparams: List[TypeDef], vparamss: List[List[ValDef]], rhs: Tree = EmptyTree)(using Context): DefDef =
536539
DefDef(nme.CONSTRUCTOR, joinParams(tparams, vparamss), TypeTree(), rhs)

compiler/src/dotty/tools/dotc/cc/CaptureAnnotation.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ case class CaptureAnnotation(refs: CaptureSet, boxed: Boolean)(cls: Symbol) exte
4444
case cr: TermRef => ref(cr)
4545
case cr: TermParamRef => untpd.Ident(cr.paramName).withType(cr)
4646
case cr: ThisType => This(cr.cls)
47+
// TODO: Will crash if the type is an annotated type, for example `cap?`
4748
}
4849
val arg = repeated(elems, TypeTree(defn.AnyType))
4950
New(symbol.typeRef, arg :: Nil)

compiler/src/dotty/tools/dotc/cc/CaptureRef.scala

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,19 @@ trait CaptureRef extends TypeProxy, ValueType:
9393
final def invalidateCaches() =
9494
myCaptureSetRunId = NoRunId
9595

96-
/** x subsumes x
97-
* this subsumes this.f
96+
/** x subsumes x
97+
* x =:= y ==> x subsumes y
98+
* x subsumes y ==> x subsumes y.f
9899
* x subsumes y ==> x* subsumes y, x subsumes y?
99100
* x subsumes y ==> x* subsumes y*, x? subsumes y?
100101
* x: x1.type /\ x1 subsumes y ==> x subsumes y
101-
* TODO: Document path cases
102+
* X = CapSet^cx, exists rx in cx, rx subsumes y ==> X subsumes y
103+
* Y = CapSet^cy, forall ry in cy, x subsumes ry ==> x subsumes Y
104+
* X: CapSet^c1...CapSet^c2, (CapSet^c1) subsumes y ==> X subsumes y
105+
* Y: CapSet^c1...CapSet^c2, x subsumes (CapSet^c2) ==> x subsumes Y
106+
* Contains[X, y] ==> X subsumes y
107+
*
108+
* TODO: Document cases with more comments.
102109
*/
103110
final def subsumes(y: CaptureRef)(using Context): Boolean =
104111

@@ -135,14 +142,29 @@ trait CaptureRef extends TypeProxy, ValueType:
135142
case _ => false
136143
|| viaInfo(y.info)(subsumingRefs(this, _))
137144
case MaybeCapability(y1) => this.stripMaybe.subsumes(y1)
145+
case y: TypeRef if y.derivesFrom(defn.Caps_CapSet) =>
146+
// The upper and lower bounds don't have to be in the form of `CapSet^{...}`.
147+
// They can be other capture set variables, which are bounded by `CapSet`,
148+
// like `def test[X^, Y^, Z >: X <: Y]`.
149+
y.info match
150+
case TypeBounds(_, hi: CaptureRef) => this.subsumes(hi)
151+
case _ => y.captureSetOfInfo.elems.forall(this.subsumes)
152+
case CapturingType(parent, refs) if parent.derivesFrom(defn.Caps_CapSet) =>
153+
refs.elems.forall(this.subsumes)
138154
case _ => false
139155
|| this.match
140156
case ReachCapability(x1) => x1.subsumes(y.stripReach)
141157
case x: TermRef => viaInfo(x.info)(subsumingRefs(_, y))
142158
case x: TermParamRef => subsumesExistentially(x, y)
143-
case x: TypeRef if x.symbol.info.derivesFrom(defn.Caps_CapSet) =>
144-
x.captureSetOfInfo.elems.exists(_.subsumes(y))
145-
case x: TypeRef => assumedContainsOf(x).contains(y)
159+
case x: TypeRef if assumedContainsOf(x).contains(y) => true
160+
case x: TypeRef if x.derivesFrom(defn.Caps_CapSet) =>
161+
x.info match
162+
case TypeBounds(lo: CaptureRef, _) =>
163+
lo.subsumes(y)
164+
case _ =>
165+
x.captureSetOfInfo.elems.exists(_.subsumes(y))
166+
case CapturingType(parent, refs) if parent.derivesFrom(defn.Caps_CapSet) =>
167+
refs.elems.exists(_.subsumes(y))
146168
case _ => false
147169
end subsumes
148170

compiler/src/dotty/tools/dotc/cc/CaptureSet.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ sealed abstract class CaptureSet extends Showable:
161161
def debugInfo(using Context) = i"$this accountsFor $x, which has capture set ${x.captureSetOfInfo}"
162162
def test(using Context) = reporting.trace(debugInfo):
163163
elems.exists(_.subsumes(x))
164-
|| !x.isMaxCapability && x.captureSetOfInfo.subCaptures(this, frozen = true).isOK
164+
|| !x.isMaxCapability
165+
&& !x.derivesFrom(defn.Caps_CapSet)
166+
&& x.captureSetOfInfo.subCaptures(this, frozen = true).isOK
165167
comparer match
166168
case comparer: ExplainingTypeComparer => comparer.traceIndented(debugInfo)(test)
167169
case _ => test

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,9 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
866866
if others.accountsFor(ref) then
867867
report.warning(em"redundant capture: $dom already accounts for $ref", pos)
868868

869-
if ref.captureSetOfInfo.elems.isEmpty && !ref.derivesFrom(defn.Caps_Capability) then
869+
if ref.captureSetOfInfo.elems.isEmpty
870+
&& !ref.derivesFrom(defn.Caps_Capability)
871+
&& !ref.derivesFrom(defn.Caps_CapSet) then
870872
val deepStr = if ref.isReach then " deep" else ""
871873
report.error(em"$ref cannot be tracked since its$deepStr capture set is empty", pos)
872874
check(parent.captureSet, parent)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ object Feature:
3434
val pureFunctions = experimental("pureFunctions")
3535
val captureChecking = experimental("captureChecking")
3636
val into = experimental("into")
37+
val namedTuples = experimental("namedTuples")
3738
val modularity = experimental("modularity")
3839
val betterMatchTypeExtractors = experimental("betterMatchTypeExtractors")
3940
val quotedPatternsWithPolymorphicFunctions = experimental("quotedPatternsWithPolymorphicFunctions")
@@ -65,6 +66,7 @@ object Feature:
6566
(pureFunctions, "Enable pure functions for capture checking"),
6667
(captureChecking, "Enable experimental capture checking"),
6768
(into, "Allow into modifier on parameter types"),
69+
(namedTuples, "Allow named tuples"),
6870
(modularity, "Enable experimental modularity features"),
6971
(betterMatchTypeExtractors, "Enable better match type extractors"),
7072
(betterFors, "Enable improvements in `for` comprehensions")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enum MigrationVersion(val warnFrom: SourceVersion, val errorFrom: SourceVersion)
2626
case WithOperator extends MigrationVersion(`3.4`, future)
2727
case FunctionUnderscore extends MigrationVersion(`3.4`, future)
2828
case NonNamedArgumentInJavaAnnotation extends MigrationVersion(`3.6`, `3.6`)
29-
case AmbiguousNamedTupleInfixApply extends MigrationVersion(`3.6`, never)
29+
case AmbiguousNamedTupleSyntax extends MigrationVersion(`3.6`, future)
3030
case ImportWildcard extends MigrationVersion(future, future)
3131
case ImportRename extends MigrationVersion(future, future)
3232
case ParameterEnclosedByParenthesis extends MigrationVersion(future, future)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ class TypeUtils:
145145
case defn.NamedTuple(_, _) => true
146146
case _ => false
147147

148+
def derivesFromNamedTuple(using Context): Boolean = self match
149+
case defn.NamedTuple(_, _) => true
150+
case tp: MatchType =>
151+
tp.bound.derivesFromNamedTuple || tp.reduced.derivesFromNamedTuple
152+
case tp: TypeProxy => tp.superType.derivesFromNamedTuple
153+
case tp: AndType => tp.tp1.derivesFromNamedTuple || tp.tp2.derivesFromNamedTuple
154+
case tp: OrType => tp.tp1.derivesFromNamedTuple && tp.tp2.derivesFromNamedTuple
155+
case _ => false
156+
148157
/** Drop all named elements in tuple type */
149158
def stripNamedTuple(using Context): Type = self.normalized.dealias match
150159
case defn.NamedTuple(_, vals) =>

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ object Completion:
543543
.groupByName
544544

545545
val qualTpe = qual.typeOpt
546-
if qualTpe.isNamedTupleType then
546+
if qualTpe.derivesFromNamedTuple then
547547
namedTupleCompletionsFromType(qualTpe)
548548
else if qualTpe.derivesFrom(defn.SelectableClass) then
549549
val pre = if !TypeOps.isLegalPrefix(qualTpe) then Types.SkolemType(qualTpe) else qualTpe

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ object Parsers {
667667
else leading :: Nil
668668

669669
def maybeNamed(op: () => Tree): () => Tree = () =>
670-
if isIdent && in.lookahead.token == EQUALS && sourceVersion.isAtLeast(`3.6`) then
670+
if isIdent && in.lookahead.token == EQUALS && in.featureEnabled(Feature.namedTuples) then
671671
atSpan(in.offset):
672672
val name = ident()
673673
in.nextToken()
@@ -1149,8 +1149,8 @@ object Parsers {
11491149
if isType then infixOp
11501150
else infixOp.right match
11511151
case Tuple(args) if args.exists(_.isInstanceOf[NamedArg]) && !isNamedTupleOperator =>
1152-
report.errorOrMigrationWarning(AmbiguousNamedTupleInfixApply(), infixOp.right.srcPos, MigrationVersion.AmbiguousNamedTupleInfixApply)
1153-
if MigrationVersion.AmbiguousNamedTupleInfixApply.needsPatch then
1152+
report.errorOrMigrationWarning(DeprecatedInfixNamedArgumentSyntax(), infixOp.right.srcPos, MigrationVersion.AmbiguousNamedTupleSyntax)
1153+
if MigrationVersion.AmbiguousNamedTupleSyntax.needsPatch then
11541154
val asApply = cpy.Apply(infixOp)(Select(opInfo.operand, opInfo.operator.name), args)
11551155
patch(source, infixOp.span, asApply.show(using ctx.withoutColors))
11561156
asApply // allow to use pre-3.6 syntax in migration mode
@@ -2172,7 +2172,7 @@ object Parsers {
21722172

21732173
if namedOK && isIdent && in.lookahead.token == EQUALS then
21742174
commaSeparated(() => namedArgType())
2175-
else if tupleOK && isIdent && in.lookahead.isColon && sourceVersion.isAtLeast(`3.6`) then
2175+
else if tupleOK && isIdent && in.lookahead.isColon && in.featureEnabled(Feature.namedTuples) then
21762176
commaSeparated(() => namedElem())
21772177
else
21782178
commaSeparated(() => argType())
@@ -2240,7 +2240,7 @@ object Parsers {
22402240
atSpan(in.offset):
22412241
if in.isIdent(nme.UPARROW) && Feature.ccEnabled then
22422242
in.nextToken()
2243-
TypeBoundsTree(EmptyTree, makeCapsBound())
2243+
makeCapsBound()
22442244
else
22452245
TypeBoundsTree(bound(SUPERTYPE), bound(SUBTYPE))
22462246

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
11241124
def recur(t: untpd.Tree): Text = t match
11251125
case Apply(fn, Nil) => recur(fn)
11261126
case Apply(fn, args) =>
1127-
val explicitArgs = args.filterNot(_.symbol.name.is(DefaultGetterName))
1127+
val explicitArgs = args.filterNot(untpd.stripNamedArg(_).symbol.name.is(DefaultGetterName))
11281128
recur(fn) ~ "(" ~ toTextGlobal(explicitArgs, ", ") ~ ")"
11291129
case TypeApply(fn, args) => recur(fn) ~ "[" ~ toTextGlobal(args, ", ") ~ "]"
11301130
case Select(qual, nme.CONSTRUCTOR) => recur(qual)

compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMe
216216
case FinalLocalDefID // errorNumber: 200
217217
case NonNamedArgumentInJavaAnnotationID // errorNumber: 201
218218
case QuotedTypeMissingID // errorNumber: 202
219-
case AmbiguousNamedTupleAssignmentID // errorNumber: 203
220-
case AmbiguousNamedTupleInfixApplyID // errorNumber: 204
219+
case DeprecatedAssignmentSyntaxID // errorNumber: 203
220+
case DeprecatedInfixNamedArgumentSyntaxID // errorNumber: 204
221221

222222
def errorNumber = ordinal - 1
223223

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3344,21 +3344,20 @@ final class QuotedTypeMissing(tpe: Type)(using Context) extends StagingMessage(Q
33443344

33453345
end QuotedTypeMissing
33463346

3347-
final class AmbiguousNamedTupleAssignment(key: Name, value: untpd.Tree)(using Context) extends SyntaxMsg(AmbiguousNamedTupleAssignmentID):
3347+
final class DeprecatedAssignmentSyntax(key: Name, value: untpd.Tree)(using Context) extends SyntaxMsg(DeprecatedAssignmentSyntaxID):
33483348
override protected def msg(using Context): String =
3349-
i"""Ambiguous syntax: this is interpreted as a named tuple with one element,
3349+
i"""Deprecated syntax: in the future it would be interpreted as a named tuple with one element,
33503350
|not as an assignment.
33513351
|
33523352
|To assign a value, use curly braces: `{${key} = ${value}}`."""
3353-
3353+
+ Message.rewriteNotice("This", version = SourceVersion.`3.6-migration`)
3354+
33543355
override protected def explain(using Context): String = ""
33553356

3356-
class AmbiguousNamedTupleInfixApply()(using Context) extends SyntaxMsg(AmbiguousNamedTupleInfixApplyID):
3357+
class DeprecatedInfixNamedArgumentSyntax()(using Context) extends SyntaxMsg(DeprecatedInfixNamedArgumentSyntaxID):
33573358
def msg(using Context) =
3358-
"Ambigious syntax: this infix call argument list is interpreted as single named tuple argument, not as an named arguments list."
3359-
+ Message.rewriteNotice("This", version = SourceVersion.`3.6-migration`)
3359+
i"""Deprecated syntax: infix named arguments lists are deprecated; in the future it would be interpreted as a single name tuple argument.
3360+
|To avoid this warning, either remove the argument names or use dotted selection."""
3361+
+ Message.rewriteNotice("This", version = SourceVersion.`3.6-migration`)
33603362

3361-
def explain(using Context) =
3362-
i"""Starting with Scala 3.6 infix named arguments are interpretted as Named Tuple.
3363-
|
3364-
|To avoid this warning, either remove the argument names or use dotted selection."""
3363+
def explain(using Context) = ""

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ object PatternMatcher {
107107
// TODO: Drop Case once we use everywhere else `isPatmatGenerated`.
108108

109109
private def dropNamedTuple(tree: Tree): Tree =
110-
val tpe = tree.tpe.widen
110+
val tpe = tree.tpe.widenDealias
111111
if tpe.isNamedTupleType then tree.cast(tpe.stripNamedTuple) else tree
112112

113113
/** The plan `let x = rhs in body(x)` where `x` is a fresh variable */

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ trait Applications extends Compatibility {
513513
case tp => args.size
514514
}
515515

516-
!isJavaAnnotConstr(methRef.symbol) &&
516+
!isAnnotConstr(methRef.symbol) &&
517517
args.size < requiredArgNum(funType)
518518
}
519519

@@ -662,6 +662,11 @@ trait Applications extends Compatibility {
662662
def isJavaAnnotConstr(sym: Symbol): Boolean =
663663
sym.is(JavaDefined) && sym.isConstructor && sym.owner.is(JavaAnnotation)
664664

665+
666+
/** Is `sym` a constructor of an annotation? */
667+
def isAnnotConstr(sym: Symbol): Boolean =
668+
sym.isConstructor && sym.owner.isAnnotation
669+
665670
/** Match re-ordered arguments against formal parameters
666671
* @param n The position of the first parameter in formals in `methType`.
667672
*/

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ trait Implicits:
876876
|| inferView(dummyTreeOfType(from), to)
877877
(using ctx.fresh.addMode(Mode.ImplicitExploration).setExploreTyperState()).isSuccess
878878
// TODO: investigate why we can't TyperState#test here
879-
|| from.widen.isNamedTupleType && to.derivesFrom(defn.TupleClass)
879+
|| from.widen.derivesFromNamedTuple && to.derivesFrom(defn.TupleClass)
880880
&& from.widen.stripNamedTuple <:< to
881881
)
882882

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import config.MigrationVersion
2121
import config.Printers.refcheck
2222
import reporting.*
2323
import Constants.Constant
24+
import cc.stripCapturing
2425

2526
object RefChecks {
2627
import tpd.*
@@ -84,7 +85,7 @@ object RefChecks {
8485
* (Forwarding tends to hide problems by binding parameter names).
8586
*/
8687
private def upwardsThisType(cls: Symbol)(using Context) = cls.info match {
87-
case ClassInfo(_, _, _, _, tp: Type) if (tp ne cls.typeRef) && !cls.isOneOf(FinalOrModuleClass) =>
88+
case ClassInfo(_, _, _, _, tp: Type) if (tp.stripCapturing ne cls.typeRef) && !cls.isOneOf(FinalOrModuleClass) =>
8889
SkolemType(cls.appliedRef).withName(nme.this_)
8990
case _ =>
9091
cls.thisType

0 commit comments

Comments
 (0)