Skip to content

Commit 11b192c

Browse files
committed
Fix eagerly typing annotations when inferring tracked
1 parent 7c2ccd9 commit 11b192c

File tree

4 files changed

+8
-43
lines changed

4 files changed

+8
-43
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ object Feature:
108108
* feature is defined.
109109
*/
110110
def enabled(feature: TermName)(using Context): Boolean =
111-
enabledBySetting(feature) || enabledByImport(feature) || feature == modularity
111+
enabledBySetting(feature) || enabledByImport(feature)
112112

113113
/** Is auto-tupling enabled? */
114114
def autoTuplingEnabled(using Context): Boolean = !enabled(nme.noAutoTupling)

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,13 +2040,15 @@ class Namer { typer: Typer =>
20402040
(owningSym.isClass || owningSym.isAllOf(Given | Method))
20412041
&& !accessorSyms.exists(_.is(Mutable))
20422042
&& (param.hasAttachment(ContextBoundParam) || accessorSyms.exists(!_.isOneOf(PrivateLocal)))
2043-
&& psym.info.memberNames(abstractTypeNameFilter).nonEmpty
2043+
&& psym.infoDontForceAnnotsAndInferred(param).memberNames(abstractTypeNameFilter).nonEmpty
20442044

20452045
extension (sym: Symbol)
2046-
private def infoWithForceNonInferingCompleter(using Context): Type = sym.infoOrCompleter match
2047-
case tpe: LazyType if tpe.isExplicit => sym.info
2048-
case tpe if sym.isType => sym.info
2049-
case info => info
2046+
private def infoDontForceAnnotsAndInferred(tree: DefTree)(using Context): Type =
2047+
sym.infoOrCompleter match
2048+
case tpe if tree.mods.annotations.nonEmpty => tpe
2049+
case tpe: LazyType if tpe.isExplicit => sym.info
2050+
case tpe if sym.isType => sym.info
2051+
case info => info
20502052

20512053
private def maybeParamAccessors(owner: Symbol, sym: Symbol)(using Context): List[Symbol] = owner.infoOrCompleter match
20522054
case info: ClassInfo =>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
945945
case _ =>
946946
notAMemberErrorType(tree, qual, pt))
947947

948-
println(i"typedSelectWithAdapt $tree, $pt, $qual")
949948
tryType(tree, qual, rawType)
950949
.orElse(trySimplifyApply())
951950
.orElse(tryInstantiateTypeVar())

simple-tracked-inference-failures-clean.md

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
- tests/pos/i2997.scala failed
4141

4242
## Non-experimental related tests:
43-
- tests/pos/i12953.scala failed
4443
- tests/pos/i2997.scala failed
4544
- tests/pos/i20901 failed
4645

@@ -248,41 +247,6 @@ index 82e95946f9..90cfcf8e95 100644
248247
+ SOURCEFILEattr 42 [<elided source file name>]
249248
```
250249

251-
### One problem with typing annotations too early:
252-
- tests/pos/i12953.scala
253-
254-
source:
255-
```scala
256-
class Schema(impl: Class[_]) extends scala.annotation.StaticAnnotation
257-
258-
class Ann[A] extends scala.annotation.StaticAnnotation
259-
260-
case class Foo[A](@Schema(classOf[List[A]]) foo: String)
261-
case class Bar[A](@Ann[A] foo: String)
262-
def baz[A](@Ann[A] foo: String) = ()
263-
```
264-
265-
error:
266-
```scala
267-
-- [E006] Not Found Error: tests/pos/i12953.scala:5:39 -------------------------
268-
5 |case class Foo[A](@Schema(classOf[List[A]]) foo: String)
269-
| ^
270-
| Not found: type A
271-
|
272-
| longer explanation available when compiling with `-explain`
273-
-- [E006] Not Found Error: tests/pos/i12953.scala:6:23 -------------------------
274-
6 |case class Bar[A](@Ann[A] foo: String)
275-
| ^
276-
| Not found: type A
277-
|
278-
| longer explanation available when compiling with `-explain`
279-
-- Warning: tests/pos/i12953.scala:1:25 ----------------------------------------
280-
1 |class Schema(impl: Class[_]) extends scala.annotation.StaticAnnotation
281-
| ^
282-
|`_` is deprecated for wildcard arguments of types: use `?` instead
283-
|This construct can be rewritten automatically under -rewrite -source 3.4-migration.
284-
```
285-
286250
### One type checking error involving Selectable:
287251
- tests/pos/i2997.scala
288252

0 commit comments

Comments
 (0)