Skip to content

Commit e6067f8

Browse files
authored
Merge pull request scala#236 from scala/backport-lts-3.3-22368
Backport "Check if a prefix is valid before selecting from a type" to 3.3 LTS
2 parents ad6ec5e + 68ccd8a commit e6067f8

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ trait TypeAssigner {
157157
else
158158
qualType.findMember(name, pre)
159159

160-
if reallyExists(mbr) then qualType.select(name, mbr)
160+
if reallyExists(mbr) && NamedType.validPrefix(qualType) then qualType.select(name, mbr)
161161
else if qualType.isErroneous || name.toTermName == nme.ERROR then UnspecifiedErrorType
162162
else NoType
163163
end selectionType

tests/neg/i22357.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Error: tests/neg/i22357.scala:1:0 -----------------------------------------------------------------------------------
2+
1 |@([A] =>> Int) // error
3+
|^^^^^^^^^^^^^^
4+
|[A] =>> Int does not have a constructor

tests/neg/i22357.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@([A] =>> Int) // error
2+
def i = 1

tests/neg/i22357a.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Error: tests/neg/i22357a.scala:2:6 ----------------------------------------------------------------------------------
2+
2 | new ([A] =>> Int)(2) // error
3+
| ^^^^^^^^^^^^^
4+
| [A] =>> Int does not have a constructor

tests/neg/i22357a.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def main =
2+
new ([A] =>> Int)(2) // error

0 commit comments

Comments
 (0)