Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cannot compile polymorphic methods with default null value under explicit nulls #24132

Closed as not planned
@HarrisL2

Description

Compiler version

3.7.3-RC2

Minimized code

package issue
def foo[A](s: A = null) = ???

scalac local/implicit.scala -d local/out -classpath "local/out"

import issue.* 
val x = foo[String]()

scalac local/explicit.scala -Yexplicit-nulls -d local/out -classpath "local/out"

Output

-- [E007] Type Mismatch Error: local/explicit.scala:3:8 ------------------------
3 |val x = foo[String]()
 | ^^^^^^^^^^^
 |Found: Null
 |Required: String
 |Note that implicit conversions were not tried because the result of an implicit conversion
 |must be more specific than String
 |
 | longer explanation available when compiling with `-explain`
1 error found

Expectation

The default argument should not throw an error

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /