Skip to content

🐛 Allow declaring a metaclass, protocol, struct, exception, stereotype or entity after its first use - #3006

Merged
arnaudroques merged 1 commit into
plantuml:masterfrom
SwastikTripathi:fix-2668-redeclare-class-like
Nov 13, 2026
Merged

arnaudroques merged 1 commit into
plantuml:masterfrom
SwastikTripathi:fix-2668-redeclare-class-like

Conversation

@SwastikTripathi

Copy link
Copy Markdown
Contributor

Fixes #2668

A class-like element that is used in a relation before it is declared fails when the declaration uses metaclass, protocol, struct, exception, stereotype or entity:

@startuml
metaclass MetaSubclass {
}
MetaClass <|-- MetaSubclass

metaclass MetaClass {
}
@enduml
Error line 7 in file: a.puml
Some diagram description contains errors

The relation creates MetaClass as a plain class. When metaclass MetaClass comes later, CommandCreateClass / CommandCreateClassMultilines call Entity.muteToType, which only allows switching between class, abstract class, interface, enum, annotation, record and dataclass, so it returns false and the line is reported as an error. With class, interface, enum and the others in the list, the same order already works.

The change moves that list into one EnumSet and adds PROTOCOL, STRUCT, EXCEPTION, METACLASS, STEREOTYPE and ENTITY. Nothing else in muteToType changes.

Tests: two Vega non-regression cases in vega/nonreg/group2668, the reported metaclass hierarchy and one relation for each of the other five keywords (each element keeps its own marker: P, S, X, S, E). Both fail before the change. ./gradlew test --tests test.vega.VegaTest passes apart from the azure_iot, azure_simple and osa2/example stdlib cases, and the full ./gradlew test adds only StringBounderEmbeddedFontTest; those fail the same way on master on this machine.

…e or entity after its first use

A relation like "MetaClass <|-- MetaSubclass" creates MetaClass as a
class. A later "metaclass MetaClass" then failed because muteToType only
allowed switching between class, abstract class, interface, enum,
annotation, record and dataclass.

Fixes plantuml#2668
@arnaudroques
arnaudroques merged commit 592901f into plantuml:master Nov 13, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metaclass with subclass causes error

2 participants