Skip to content

Error on @throws to non-methods (align with Scala 2) #26804

Description

@tanishiking

Related to #26802 (pointed out by @SolalPirelli )

Currently, Scala 3 accepts @throws annotations on any places. However @throws is effective only on methods/constructors, and otherwise it's ignored.

Scala 2 already rejects @throws on non-methods/constructors:

import java.io.IOException
@throws(classOf[IOException])
class C
// error: @throws only allowed for methods and constructors

Proposal

Reject @throws earlier aligned with Scala 2.

Scala 2: scala/scala#9465

Metadata

Metadata

Assignees

No one assigned

    Labels

    better-errorsIssues concerned with improving confusing/unhelpful diagnostic messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions