Unexpected "Cannot add supertype 'X' to sealed type 'Y'"

Open
#2,593 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
compilers

Research direction

Open the attached mydsl.zip sample and reproduce the marker for the CallOrAssignStatement parser rule shown in the issue. Trace how the declared return type and the assigned actions are validated, then confirm that a valid rule no longer reports the unexpected sealed-type error.

Written by the indexing model from the issue text.

Description

bug confirmed

For the following parser rule I get an error marker "Unexpected "Cannot add supertype 'Statement' to sealed type 'FeatureCall'":

CallOrAssignStatement returns Statement:
	FeatureCall
	(
		  {AssignStatement.target=current} ':=' value=INT
		| {CallStatement.expression=current}
	)
	';'
;

Since the rule should always return an instance of AssignStatement or CallStatement it seems wrong to me that Xtext requires FeatureCall to also be a subtype of the declared return type Statement. Or what am I missing here?

Full sample project attached: mydsl.zip

Dominant language
Java
Stars
831
Forks
330
Avg merge
3d 7h
Merged PRs (30d)
12

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from eclipse-xtext/xtext

All issues in eclipse-xtext/xtext

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.