Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2002,11 +2002,13 @@ class Definitions {
* - the upper bound of a TypeParamRef in the current constraint
*/
def asContextFunctionType(tp: Type)(using Context): Type =
tp.stripNull().stripTypeVar.dealias match
tp.stripTypeVar.dealias match
case tp1: TypeParamRef if ctx.typerState.constraint.contains(tp1) =>
asContextFunctionType(TypeComparer.bounds(tp1).hiBound)
case tp1 @ PolyFunctionOf(mt: MethodType) if mt.isContextualMethod =>
tp1
case tp: FlexibleType =>
asContextFunctionType(tp.hi)
case tp1 =>
if tp1.typeSymbol.name.isContextFunction && isFunctionNType(tp1) then tp1
else NoType
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Test:
val x: ((a: String) ?=> Int) | Null = null

val x2: ((a: String) ?=> Int) | Null = (s: String) ?=> 42

val y: ((a: String) ?=> Int) | String = "hello"

def f(g: ((a: String) ?=> Int) | Null = null) = ???

Loading